Telegram Group & Telegram Channel
ℹ️ Как компьютеры находят простые числа в тысячи раз быстрее, чем ты на бумажке

📌 Что делает решето Эратосфена

Находит все простые числа от 1 до N — быстро, эффективно и без перебора делителей.

➡️ Как это работает

▪️ Создаём массив от 2 до N

▪️ Берём первое невычеркнутое число p

▪️ Вычеркиваем все кратные p

▪️ Переходим к следующему невычеркнутому числу

▪️ Повторяем, пока p² <= N

Пример на Python:
def eratosthenes(n):
sieve = [True] * (n+1)
sieve[0:2] = [False, False]
for i in range(2, int(n**0.5) + 1):
if sieve[i]:
for j in range(i*i, n+1, i):
sieve[j] = False
return [i for i, prime in enumerate(sieve) if prime]


🔵 Чтобы знать об алгоритмах все, забирайте наш курс «Алгоритмы и структуры данных»

Proglib Academy #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/proglib_academy/2771
Create:
Last Update:

ℹ️ Как компьютеры находят простые числа в тысячи раз быстрее, чем ты на бумажке

📌 Что делает решето Эратосфена

Находит все простые числа от 1 до N — быстро, эффективно и без перебора делителей.

➡️ Как это работает

▪️ Создаём массив от 2 до N

▪️ Берём первое невычеркнутое число p

▪️ Вычеркиваем все кратные p

▪️ Переходим к следующему невычеркнутому числу

▪️ Повторяем, пока p² <= N

Пример на Python:

def eratosthenes(n):
sieve = [True] * (n+1)
sieve[0:2] = [False, False]
for i in range(2, int(n**0.5) + 1):
if sieve[i]:
for j in range(i*i, n+1, i):
sieve[j] = False
return [i for i, prime in enumerate(sieve) if prime]


🔵 Чтобы знать об алгоритмах все, забирайте наш курс «Алгоритмы и структуры данных»

Proglib Academy #буст

BY Proglib.academy | IT-курсы




Share with your friend now:
tg-me.com/proglib_academy/2771

View MORE
Open in Telegram


Proglib academy | IT курсы Telegram | DID YOU KNOW?

Date: |

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.

If riding a bucking bronco is your idea of fun, you’re going to love what the stock market has in store. Consider this past week’s ride a preview.The week’s action didn’t look like much, if you didn’t know better. The Dow Jones Industrial Average rose 213.12 points or 0.6%, while the S&P 500 advanced 0.5%, and the Nasdaq Composite ended little changed.

Proglib academy | IT курсы from in


Telegram Proglib.academy | IT-курсы
FROM USA